package yaner.hotel.manager.resource.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yaner.hotel.manager.common.dto.user.UserAddDto;
import yaner.hotel.manager.common.dto.user.UserDto;
import yaner.hotel.manager.common.dto.user.UserUpdateDto;
import yaner.hotel.manager.common.vo.ResponseVo;
import yaner.hotel.manager.common.vo.UserVo;
import yaner.hotel.manager.resource.service.IUserService;

import java.util.List;

/**
 * @Author kf-leig
 * @Description 用户管理
 * @Date 2024年05月22日10:13:28
**/
@RestController
public class UserController {
    @Autowired
    private IUserService userService;
    @RequestMapping("/user-list")
    public ResponseVo<List<UserVo>> list(@RequestBody UserDto userDto) {
        List<UserVo> userVos = userService.userList(userDto);
        return ResponseVo.success(userVos);
    }

    @GetMapping("/get-user-info")
    public ResponseVo<UserVo> getUser(@RequestParam("userId") String userId) {
        UserVo userInfo = userService.getUserInfo(userId);
        return ResponseVo.success(userInfo);
    }

    @PostMapping("/add-user-info")
    public ResponseVo<String> addUser(@RequestBody UserAddDto userAddDto) {
        String addUserInfo = userService.addUserInfo(userAddDto);
        return ResponseVo.success(addUserInfo);
    }

    @PostMapping("/update-user-info")
    public ResponseVo<String> updateUser(@RequestBody UserUpdateDto userUpdateDto) {
        String updateUserInfo = userService.updateUserInfo(userUpdateDto);
        return ResponseVo.success(updateUserInfo);
    }

    @DeleteMapping("/delete-user-info")
    public ResponseVo<String> deleteUser(@RequestParam("userId") String userId) {
        String deleteUserInfo = userService.deleteUserInfo(userId);
        return ResponseVo.success(deleteUserInfo);
    }

    @PostMapping("/update-user-status")
    public ResponseVo<String> updateUserStatus(@RequestBody UserUpdateDto userUpdateDto) {
        String updateUserInfo = userService.updateUserStatus(userUpdateDto);
        return ResponseVo.success(updateUserInfo);
    }

    @PostMapping("/update-user-password")
    public ResponseVo<String> updateUserPassword(@RequestBody UserUpdateDto userUpdateDto) {
        String updateUserInfo = userService.updateUserPassword(userUpdateDto);
        return ResponseVo.success(updateUserInfo);
    }

}
